package com.beidouapp.security.mvc;

import com.beidouapp.domain.pojo.Role;
import com.beidouapp.domain.pojo.RoleGroup;
import com.beidouapp.security.model.ReturnDataInfo;
import com.beidouapp.service.RoleGroupService;
import com.beidouapp.service.RoleService;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static java.lang.Integer.valueOf;

@Controller
@RequestMapping(value = "/roleGroup")
public class RoleGroupController {
    private static final Logger logger = LoggerFactory.getLogger(RoleGroupController.class);

    @Autowired
    private RoleGroupService roleGroupService;

    @RequestMapping(value = "/listAll", method = RequestMethod.GET)
    public
    @ResponseBody
    ReturnDataInfo<RoleGroup> listPageRoles(HttpSession session, HttpServletRequest request) {
        try {
            RoleGroup rg = new RoleGroup();
            List<RoleGroup> list = roleGroupService.findRoleGroups(rg);
            return ReturnDataInfo.createSuccessfulExecuteResults(list);
        } catch (Exception ex) {
            logger.error("listPageRoles is failed. because {}", ex.getLocalizedMessage(), ex);
            return ReturnDataInfo.createFailedExecuteResult(ex.getMessage());
        }
    }
}
